<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;

AppAsset::register($this);
?>
<style>
    .navbar-brand {
        font-size: 24px !important;
    }
</style>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>

<div class="wrap">
    <?php
    NavBar::begin([
        'brandLabel' => '抽油机控制平台',
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
    $items = [
        ['label' => '设备列表', 'url' => ['site/index']],
        ['label' => '用户管理', 'url' => ['/table/users']],
    ];
    if (Yii::$app->loginState->checkLogin()) {
        $items[] = [
            'label' => Yii::$app->loginState->getState('username'),
            'items' => [
                ['label' => '退出登录', 'url' => ['/site/logout']],
                ['label' => '修改密码', 'url' => ['/site/change-password']],
            ],
            'options' => [
                    'style' => [
                            'min-width' => '86px'
                    ]
            ]
        ];
    }
    if (!Yii::$app->user->isGuest) {
        $items[] = ['label' => Yii::$app->user->identity->username, 'url' => ['/site/index']];
    }

    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'items' => $items,
    ]);
    NavBar::end();
    ?>

    <div class="container">
        <?= $content ?>
    </div>
</div>

<footer class="footer">
    <div class="container">
        <p class="pull-left"></p>
    </div>
</footer>

<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
